package mapper;

import model.vo.PrescriptionDrugVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PrescriptionDrugMapper {

    @Select("select p.id pid,d.name,db.id bid,pd.amount,db.production_date,db.residue_stock from prescription p\n" +
            "join prescription_detail pd on p.id = pd.prescription_id\n" +
            "join prescription_batch_detail pbd on pd.id = pbd.prescription_detail_id\n" +
            "join drug d on pd.drug_id = d.id\n" +
            "join drug_batch db on d.id = db.drug_id\n" +
            "and  pbd.drug_batch_id = db.id\n" +
            "where p.id = #{id}")
    List<PrescriptionDrugVo> findAll(Integer id);
}
